#include "path_point.h"
#include <ltobjectcreate.h>
#include <iltmessage.h>
#include <iltcommon.h>
#include "msgids.h"
#include "serverinterfaces.h"

BEGIN_CLASS(path_point)
ADD_REALPROP(min_speed, 5.0f)
ADD_REALPROP(max_speed, 100.0f)
END_CLASS_DEFAULT_FLAGS(path_point, BaseClass, LTNULL, LTNULL, CF_ALWAYSLOAD| CF_WORLDMODEL)

   
uint32 path_point::EngineMessageFn( uint32 messageID, void *pData, float fData )
{
	switch (messageID)
	{
	case MID_PRECREATE:
		return PreCreate(pData, fData);
	default:
		break;
	}

	// Pass the message along to parent class.
	return BaseClass::EngineMessageFn(messageID, pData, fData);

}

uint32 path_point::PreCreate( void *pData, float fData )
{
	// Let parent class handle it first
	BaseClass::EngineMessageFn(MID_PRECREATE, pData, fData);

	// Cast pData to a ObjectCreateStruct* for convenience
	ObjectCreateStruct* pStruct = (ObjectCreateStruct*)pData;

	// Set the object type to OT_NORMAL
	pStruct->m_ObjectType = OT_WORLDMODEL;

	pStruct->m_Flags = FLAG_VISIBLE;// | FLAG_SOLID;
	pStruct->m_Flags2 |= FLAG2_ADDITIVE | FLAG2_FORCETRANSLUCENT;

	// Check to see if this is coming from a world file
	if(fData == PRECREATE_WORLDFILE)
	{
		ReadProps(pStruct);
	}

	// Return default of 1
	return 1;

}



void path_point::ReadProps( ObjectCreateStruct* pStruct )
{
	g_pLTServer->GetPropString("Name", pStruct->m_Filename, MAX_CS_FILENAME_LEN);

}